# $Id: PKGBUILD 87789 2013-04-06 16:50:31Z bgyorgy $
# Maintainer: Kaiting Chen <kaitocracy@gmail.com>
# Contributor: Aaron Schaefer <aaron@elasticdog.com>

pkgname=duplicity
pkgver=0.6.21
pkgrel=2
pkgdesc='A utility for encrypted, bandwidth-efficient backups using the rsync algorithm.'
arch=('i686' 'x86_64')
url='http://www.nongnu.org/duplicity/'
license=('GPL')
depends=('gnupg' 'librsync' 'ncftp' 'python2-paramiko')
optdepends=('lftp: FTPS backend'
            'python2-boto: Amazon S3 backend'
            'python2-gobject: GIO backend'
            'gvfs: GIO backend'
            'python2-gdata: Google Docs backend'
            'python2-httplib2: Ubuntu One backend'
            'python2-oauthlib: Ubuntu One backend'
            'rsync: rsync backend')
source=("http://savannah.nongnu.org/download/$pkgname/$pkgname-$pkgver.tar.gz"{,.sig})
md5sums=('4ade1de475e0af64211bb6933b593057'
         '3521d679ba7dff46653313aa3b3e6855')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  # python2 fix
  for file in $(find . -name '*.py' -print); do
    sed -i 's_^#!.*/usr/bin/python$_#!/usr/bin/python2_' $file
    sed -i 's_^#!.*/usr/bin/env.*python$_#!/usr/bin/env python2_' $file
  done
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  
  python2 setup.py install --root="$pkgdir" --optimize=1

  # fix broken documentation permissions until upstream does (FS#27301)
  chmod 644 "$pkgdir/usr/share/man/man1/$pkgname.1"
  chmod 644 "$pkgdir/usr/share/man/man1/rdiffdir.1"
  chmod 644 "$pkgdir/usr/share/doc/$pkgname-$pkgver"/*
}
